package com.yanqu.road.server.manager.systemgroup.newmonopolymkt;

import com.yanqu.road.dao.impl.nenmonopolymarket.NewMonopolyMarketResConfigDaoImpl;
import com.yanqu.road.entity.systemgroup.newmonopolymarket.config.NewMonopolyMarketResConfigData;
import com.yanqu.road.server.TempMgr;

import java.util.ArrayList;
import java.util.List;

public class CrossNewMonopolyMarketConfigMgr extends TempMgr {

    //资源点配表
    private static List<NewMonopolyMarketResConfigData> resConfigList = new ArrayList<>();


    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        resConfigList = new NewMonopolyMarketResConfigDaoImpl().getMonopolyMarketResConfigDataList();
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    public static List<NewMonopolyMarketResConfigData> getResConfigListByType(int type){
        List<NewMonopolyMarketResConfigData> result = new ArrayList<>();
        for (NewMonopolyMarketResConfigData configData : resConfigList) {
            if(configData.getType() == type){
                result.add(configData);
            }
        }
        return result;
    }

    public static NewMonopolyMarketResConfigData getMonopolyMarketResConfigData(int type, int lv){
        for (NewMonopolyMarketResConfigData configData : resConfigList) {
            if(configData.getType() == type && configData.getLevel() == lv){
                return configData;
            }
        }
        return null;
    }

    public static List<NewMonopolyMarketResConfigData> getResConfigList() {
        return resConfigList;
    }
}
